public class SampleFactory {
    public static void main(String[] args) {
        Factory factoryA = new FactoryA();
        Product productA = factoryA.createProduct();
        productA.info();
        Factory factoryB = new FactoryB();
        Product productB = factoryB.createProduct();
        productB.info();
    }
}

interface Factory {
    Product createProduct();
}

class FactoryA implements Factory {

    @Override
    public Product createProduct() {
        return new Phone();
    }
}

class FactoryB implements Factory {

    @Override
    public Product createProduct() {
        return new Computer();
    }
}

abstract class Product {
    abstract void info();
}

class Phone extends Product {
    @Override
    void info() {
        System.out.println("手机");
    }
}

class Computer extends Product {
    @Override
    void info() {
        System.out.println("电脑");
    }
}